<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="iwpl.project.entities.Roles"%>
<%@page import="iwpl.project.dao.RolesDAO"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<script type="text/javascript">
	function Editting() 
	{
		var text = confirm("Are you sure ?");

		if (text == true) {
			//alert("Okey, Deleted !!!");
			location.href = "./servlet/MyControl?delete=" + id+"&action=Delete";
		} 
		else {
			alert("What ever !!!");
		}
	}
</script>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<center>

	<html>
		<head>
			<base href="<%=basePath%>">
<script type="text/javascript" src="js/jquery-Source.js"></script>
		<script type="text/javascript" src="js/jquery-Validation.js"></script>
		<link href="css/CommonCSS.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript">
			$(document).ready(function() {
				$("#Department").validate();
			});
		</script>
			<title>update Roles</title>

			<meta http-equiv="pragma" content="no-cache">
			<meta http-equiv="cache-control" content="no-cache">
			<meta http-equiv="expires" content="0">
			<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
			<meta http-equiv="description" content="This is my page">
			<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
			<style type="text/css">
.style1 {
	width: 100%;
	height: 142px;
}

.style2 {
	width: 55px;
}
</style>
		</head>

		<body>
			<form name="frmUpdateRole" id="Department" action="./servlet/Control_Role"
				method="get">
				<table cellpadding="0" cellspacing="0">
					<tr>
						<td>



							<table align="center">
								<tr>
									<%
										RolesDAO rol = new RolesDAO();
										String rid= "0";
										String rolename="";	
																		
										Integer id;
										int sActive=0;
										String disc="";
										Roles data=null;
										try
										{
											if(request.getParameter("rid")!=null)
											{
												id = Integer.parseInt(request.getParameter("rid"));
												
												 data = rol.findById(id);
												rid = data.getId().toString();
												rolename = data.getRoleName();
												disc= data.getDescription();
											
												if(data.getActive())
	            									{
								            			sActive = 1;
								            		}
								            		else
								            		{
								            			sActive = 0;
								            		}
											}
												else
											{
												response.sendRedirect("Manage_Roles.jsp");
											}
										}
											
											catch (Exception e) {
												// TODO: handle exception
												
										//endRedirect("../Manage_Roles.jsp?");
												System.out.print(e.getMessage());
											}
									%>
									<td colspan="3" align="center">
										UpdateRole
									</td>
								</tr>
								<tr>
									<td>
									<input type="hidden" name="action" value="Update" />
										<input type="hidden" name="hidrID" value="<%=rid%>" />
									</td>
								</tr>
								<tr>
									<td>
										RoleName:
									</td>
									<td colspan="2">
										<input type="text" class="required" readonly="readonly" name="txtRoleName" value="<%=rolename%>" />
									</td>

								</tr>
								<tr>
									<td>
										Active:
									</td>
									<td colspan="2">
										<%
										if (sActive == 1) {
												out.println("<input type=\"checkbox\" name=\"chkActive\"");
												out.println("checked=\"checked\" />");
											} else {
												out.println("<input type=\"checkbox\" name=\"chkActive\" />");
											}
										%>
										<%= data.getActive().toString() %>
									</td>
								</tr>
								<tr>
									<td>
										Description:
									</td>
									<td colspan="2">
										<input type="text" class="required" name="txtDescription" value="<%=disc%>" />
									</td>
								</tr>

								<tr>
									<td>
										<input type="submit" name="btnSave" value="Save"  />
									</td>
									<td>
										<input type="button" name="Back" value="Cancel" onclick="self.location='Manage_Roles.jsp'"/>
									</td>
								</tr>
							</table>


						</td>
					</tr>
				</table>
			</form>
		</body>
	</html>
</center>